public class Demo12 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            int n = 10;
            while (n-- != 0){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        //在调用start之前获取状态, 此时就是NEW状态
        System.out.println(t.getState());
        t.start();

        for(int i = 0; i < 5; i++)
        {
            System.out.println(t.getState());
            Thread.sleep(1000);
        }

        t.join();
        //在结束之后, 获取线程地状态, 此时TERMINATED状态
        System.out.println(t.getState());
    }
}
